home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / lib / tex / natsci.bst < prev    next >
Encoding:
BibTeX style  |  1988-04-18  |  17.7 KB  |  956 lines

  1. %% BibTeX `natsci' family
  2. %
  3. % **********************************************************
  4. % ***** This will not work with BibTeX 0.99a or later ******
  5. % **********************************************************
  6. %
  7. %% 08 jan 87 gildea natural sciences version created from this version:
  8.     % version 0.98c for BibTeX versions 0.98i or later, LaTeX version 2.08
  9.     % Copyright (C) 1985, all rights reserved
  10.     % Copying of this file is authorized only if either
  11.     % (1) you make absolutely no changes to your copy, including name, or
  12.     % (2) if you do make changes, you name it something other than
  13.     % btxbst.doc, plain.bst, unsrt.bst, alpha.bst, and abbrv.bst
  14.     % This restriction helps ensure that all standard styles are identical
  15.  
  16. %% Copyright (c) 1987 by Stephen Gildea
  17. %% Permission to copy all or part of this work is granted, provided
  18. %% that the copies are not made or distributed for resale, and that
  19. %% the copyright notice and this notice are retained.
  20. %% 
  21. %% THIS WORK IS PROVIDED ON AN "AS IS" BASIS.  THE AUTHOR PROVIDES NO
  22. %% WARRANTY WHATSOEVER, EITHER EXPRESS OR IMPLIED, REGARDING THE WORK,
  23. %% INCLUDING WARRANTIES WITH RESPECT TO ITS MERCHANTABILITY OR FITNESS
  24. %% FOR ANY PARTICULAR PURPOSE.
  25.  
  26. %% Natural Sciences bibliography format:
  27. %%  citations in the text look like (Gildea, 1987).
  28. %%  There are no labels in the bibliography.
  29. %%  There are no "sentences"; commas separate all parts of an entry.
  30. %%  The first author's name is reversed: Last, First.
  31. %%  The number is not listed, just the volume.
  32. %%  For two entries by the same author in the same year, a letter ("a",
  33. %%    "b", etc.) is added to the year in the reference list as well as in
  34. %%    the citation label.
  35. %%
  36. %% Other things fixed by Gildea:
  37. %%  The editors are listed after, not before, the booktitle.
  38. %%  The comma after a field is italicized if the field was.
  39.  
  40. %% Note to users:
  41. %%  Since the natsci format does not use labels in the bibliography,
  42. %%  the LaTeX style needs to be modified slightly.  As a minimum,
  43. %%  redefine \@biblabel as follows:
  44. %%
  45. %%  \def\@biblabel#1{\hfill}
  46. %%
  47. %%  To get the indenting right, the following should be added to the
  48. %%  list initialization in the definition of the thebibliography
  49. %%  environment:
  50. %%
  51. %%  \itemindent=-\leftmargin
  52. %%
  53. %%  Of course, the best solution is to use a LaTeX style that was designed
  54. %%  to use this bibliography style.
  55.  
  56. %% The commented source is available from the author.
  57. %% If you make any improvements, I'd like to hear about them.
  58. %% Stephen Gildea
  59. %% MIT Earth Resources Lab
  60. %% Cambridge, Mass. 02139
  61. %% mit-erl!gildea
  62. %% gildea@erl.mit.edu
  63.  
  64. ENTRY
  65.   { address
  66.     author
  67.     booktitle
  68.     chapter
  69.     edition
  70.     editor
  71.     howpublished
  72.     institution
  73.     journal
  74.     key
  75.     month
  76.     note
  77.     number
  78.     organization
  79.     pages
  80.     publisher
  81.     school
  82.     series
  83.     title
  84.     type
  85.     volume
  86.     year
  87.   }
  88.   {}
  89.  
  90.   { label extra.label sort.label }
  91.  
  92. INTEGERS { output.state before.all mid.sentence after.sentence after.block }
  93.  
  94. FUNCTION {init.state.consts}
  95. { 'before.all #0 :=
  96.   'mid.sentence #1 :=
  97.   'after.sentence #2 :=
  98.   'after.block #3 :=
  99. }
  100.  
  101. STRINGS { s t }
  102.  
  103. FUNCTION {add.comma}
  104. { duplicate$
  105.   #-1 #1 substring$ "}" =
  106.     { #-2 #1024 substring$ ",} " * }
  107.     { ", " * }
  108.   if$
  109. }
  110.  
  111. FUNCTION {output.nonnull}
  112. { 's swap$ :=
  113.   output.state mid.sentence =
  114.     { add.comma write$ }
  115.     { output.state after.block =
  116.     { add.period$ write$
  117.       newline$
  118.       "\newblock " write$
  119.     }
  120.     { output.state before.all =
  121.         'write$
  122.         { add.period$ " " * write$ }
  123.       if$
  124.     }
  125.       if$
  126.     }
  127.   if$
  128.   'output.state mid.sentence :=
  129.   s
  130. }
  131.  
  132. FUNCTION {output}
  133. { 's swap$ :=
  134.   s "" =
  135.     'skip$
  136.     { s output.nonnull }
  137.   if$
  138. }
  139.  
  140. FUNCTION {output.check}
  141. { 's swap$ :=
  142.   't swap$ :=
  143.   s "" =
  144.     { "Warning: the " t * " shouldn't be empty in " * cite$ * top$ }
  145.     { s output.nonnull }
  146.   if$
  147. }
  148.  
  149. FUNCTION {output.bibitem}
  150. { newline$
  151.  
  152.   "\bibitem[" write$
  153.   label write$
  154.   "]{" write$
  155.  
  156.   cite$ write$
  157.   "}" write$
  158.   newline$
  159.   ""
  160.   'output.state before.all :=
  161. }
  162.  
  163. FUNCTION {fin.entry}
  164. { add.period$
  165.   write$
  166.   newline$
  167. }
  168.  
  169. FUNCTION {new.block}
  170. { output.state before.all =
  171.     'skip$
  172.     { 'output.state after.block := }
  173.   if$
  174. }
  175.  
  176. FUNCTION {new.sentence}
  177. { output.state after.block =
  178.     'skip$
  179.     { output.state before.all =
  180.     'skip$
  181.     { 'output.state after.sentence := }
  182.       if$
  183.     }
  184.   if$
  185. }
  186.  
  187. FUNCTION {not}
  188. {   { #0 }
  189.     { #1 }
  190.   if$
  191. }
  192.  
  193. FUNCTION {and}
  194. {   'skip$
  195.     { pop$ #0 }
  196.   if$
  197. }
  198.  
  199. FUNCTION {or}
  200. {   { pop$ #1 }
  201.     'skip$
  202.   if$
  203. }
  204.  
  205. FUNCTION {field.or.null}
  206. { duplicate$
  207.   missing$
  208.     { pop$ "" }
  209.     'skip$
  210.   if$
  211. }
  212.  
  213. FUNCTION {italicize}
  214. { 's swap$ :=
  215.   s "" =
  216.     { "" }
  217.     { "{\it " s * "}" * }
  218.   if$
  219. }
  220.  
  221. INTEGERS { nameptr namesleft numnames }
  222.  
  223. STRINGS {nameresult}
  224.  
  225. FUNCTION {format.names}
  226. { 's swap$ :=
  227.   'nameptr #1 :=
  228.   'nameresult "" :=
  229.   'numnames s num.names$ :=
  230.   'namesleft numnames :=
  231.     { namesleft #0 > }
  232.     {
  233.  
  234.       't s nameptr "{f.~}{vv~}{ll}{, jj}" format.name$ :=
  235.  
  236.       nameptr #1 >
  237.     { namesleft #1 >
  238.         { 'nameresult nameresult ", " * t * := }
  239.         { numnames #2 >
  240.         { 'nameresult nameresult "," * := }
  241.         'skip$
  242.           if$
  243.           t "others" =
  244.         { 'nameresult nameresult " et al." * := }
  245.         { 'nameresult nameresult " and " * t * := }
  246.           if$
  247.         }
  248.       if$
  249.     }
  250.     { 'nameresult nameresult t * := }
  251.       if$
  252.       'nameptr nameptr #1 + :=
  253.       'namesleft namesleft #1 - :=
  254.     }
  255.   while$
  256.   nameresult
  257. }
  258.  
  259. FUNCTION {format.names.reverse1}
  260. { 's swap$ :=
  261.   'nameptr #1 :=
  262.   'nameresult "" :=
  263.   'numnames s num.names$ :=
  264.   'namesleft numnames :=
  265.     { namesleft #0 > }
  266.     {
  267.       nameptr #1 >
  268.     { 
  269.  
  270.           't s nameptr "{f.~}{vv~}{ll}{, jj}" format.name$ :=
  271.  
  272.           namesleft #1 >
  273.         { 'nameresult nameresult ", " * t * := }
  274.         { numnames #2 >
  275.         { 'nameresult nameresult "," * := }
  276.         'skip$
  277.           if$
  278.           t "others" =
  279.         { 'nameresult nameresult " et al." * := }
  280.         { 'nameresult nameresult " and " * t * := }
  281.           if$
  282.         }
  283.       if$
  284.     }
  285.     {
  286.  
  287.           't s nameptr "{vv~}{ll}{, jj}{, f.}" format.name$ :=
  288.  
  289.           'nameresult nameresult t * :=
  290.         }
  291.       if$
  292.       'nameptr nameptr #1 + :=
  293.       'namesleft namesleft #1 - :=
  294.     }
  295.   while$
  296.   nameresult
  297. }
  298.  
  299. FUNCTION {format.authors}
  300. { author missing$
  301.     { "" }
  302.     { author format.names.reverse1 }
  303.   if$
  304. }
  305.  
  306. FUNCTION {format.eds}
  307. { editor missing$
  308.     { "" }
  309.     { editor num.names$ #1 >
  310.     { editor format.names.reverse1 " (eds.)" * }
  311.     { editor format.names.reverse1 " (ed.)" * }
  312.       if$
  313.     }
  314.   if$
  315. }
  316.  
  317. FUNCTION {format.editors}
  318. { editor missing$
  319.     { "" }
  320.     { editor num.names$ #1 >
  321.     { editor format.names ", editors" * }
  322.     { editor format.names ", editor" * }
  323.       if$
  324.     }
  325.   if$
  326. }
  327.  
  328. FUNCTION {format.edited.by}
  329. { editor missing$
  330.     'skip$
  331.     { add.comma "edited by " * editor format.names * }
  332.   if$
  333. }
  334.  
  335. FUNCTION {format.title}
  336.  
  337. { title missing$
  338.     { "" }
  339.     { title "ul" change.case$ }
  340.   if$
  341.  
  342. }
  343.  
  344. FUNCTION {entry.string.max} { #100 }
  345.  
  346. FUNCTION {global.string.max} { #300 }
  347.  
  348. STRINGS {pageresult}
  349.  
  350. FUNCTION {n.dashify}
  351. { 't swap$ :=
  352.   'pageresult "" :=
  353.     { t "" = not }
  354.     { t #1 #1 substring$ "-" =
  355.     { t #1 #2 substring$ "--" = not
  356.         { 'pageresult pageresult "--" * :=
  357.           't t #2 global.string.max substring$ :=
  358.         }
  359.         {   { t #1 #1 substring$ "-" = }
  360.         { 'pageresult pageresult "-" * :=
  361.           't t #2 global.string.max substring$ :=
  362.         }
  363.           while$
  364.         }
  365.       if$
  366.     }
  367.     { 'pageresult pageresult t #1 #1 substring$ * :=
  368.       't t #2 global.string.max substring$ :=
  369.     }
  370.       if$
  371.     }
  372.   while$
  373.   pageresult
  374. }
  375.  
  376. FUNCTION {format.date}
  377. { year missing$
  378.     { month missing$
  379.     { "" }
  380.     { "Warning: there's a month but no year in " cite$ * top$
  381.       month
  382.     }
  383.       if$
  384.     }
  385.     { month missing$
  386.     { year }
  387.     { month " " * year * }
  388.       if$
  389.       extra.label *
  390.     }
  391.   if$
  392. }
  393.  
  394. FUNCTION {format.btitle}
  395. { title field.or.null
  396.   italicize
  397. }
  398.  
  399. FUNCTION {format.bvolume}
  400. { volume missing$
  401.     { series missing$
  402.     { "" }
  403.     { series italicize }
  404.       if$
  405.     }
  406.     { "vol.~" volume *
  407.       series missing$
  408.     'skip$
  409.     { " of " * series italicize * }
  410.       if$
  411.     }
  412.   if$
  413. }
  414.  
  415. FUNCTION {format.edition}
  416. { edition missing$
  417.     { "" }
  418.     { edition "ll" change.case$ " edition" * }
  419.   if$
  420. }
  421.  
  422. INTEGERS {multiresult}
  423.  
  424. FUNCTION {multi.page.check}
  425. { 't swap$ :=
  426.   'multiresult #0 :=
  427.     { multiresult not
  428.       t "" = not
  429.       and
  430.     }
  431.     { t #1 #1 substring$ "-" =
  432.       t #1 #1 substring$ "," =
  433.       or
  434.     { 'multiresult #1 := }
  435.     { 't t #2 global.string.max substring$ := }
  436.       if$
  437.     }
  438.   while$
  439.   multiresult
  440. }
  441.  
  442. FUNCTION {format.pages}
  443. { pages missing$
  444.     { "" }
  445.     { pages multi.page.check
  446.     { "pp.~" pages n.dashify * }
  447.     { "p.~" pages n.dashify * }
  448.       if$
  449.     }
  450.   if$
  451. }
  452.  
  453. FUNCTION {format.vol.num.pages}
  454. { volume field.or.null
  455.   number missing$
  456.     'skip$
  457.     { "(" number * ")" * *
  458.       volume missing$
  459.     { "Warning: there's a number but no volume in " cite$ * top$ }
  460.     'skip$
  461.       if$
  462.     }
  463.   if$
  464.   pages missing$
  465.     'skip$
  466.     { duplicate$ "" =
  467.     'skip$
  468.     { ":" * }
  469.       if$
  470.       pages n.dashify *
  471.     }
  472.   if$
  473. }
  474.  
  475. FUNCTION {format.vol.pages}
  476. { volume missing$
  477.     'skip$
  478.     {volume italicize}
  479.   if$
  480.   pages missing$
  481.     'skip$
  482.     { duplicate$ "" =
  483.     'skip$
  484.     { add.comma }
  485.       if$
  486.       pages n.dashify *
  487.     }
  488.   if$
  489. }
  490.  
  491. FUNCTION {format.chapter.pages}
  492. { chapter missing$
  493.     'format.pages
  494.     { "chapter~" chapter *
  495.       pages missing$
  496.     'skip$
  497.     { add.comma format.pages * }
  498.       if$
  499.     }
  500.   if$
  501. }
  502.  
  503. FUNCTION {format.in.ed.booktitle}
  504. { booktitle missing$
  505.     { "" }
  506.     { 's format.editors :=
  507.       s "" =
  508.     { "In " booktitle italicize * }
  509.     { "In " s * add.comma booktitle italicize * }
  510.       if$
  511.     }
  512.   if$
  513. }
  514.  
  515. FUNCTION {format.in.booktitle.ed}
  516. { booktitle missing$
  517.     { "" }
  518.     { "in " booktitle italicize *
  519.       format.edited.by
  520.     }
  521.   if$
  522. }
  523.  
  524. FUNCTION {format.tr.number}
  525. { type missing$
  526.     { "Technical Report" }
  527.     { type }
  528.   if$
  529.   number missing$
  530.     'skip$
  531.     { "~" * number * }
  532.   if$
  533. }
  534.  
  535. FUNCTION {article}
  536. { output.bibitem
  537.   "author" format.authors output.check
  538.   "title" format.title output.check
  539.   "journal" journal field.or.null italicize output.check
  540.   format.vol.pages output
  541.   "year" format.date output.check
  542.   note field.or.null output
  543.   fin.entry
  544. }
  545.  
  546. FUNCTION {book}
  547. { output.bibitem
  548.   author missing$
  549.     { "author and editor" format.eds output.check }
  550.     { "author" format.authors output.check }
  551.   if$
  552.   "title" format.btitle output.check
  553.   format.bvolume output
  554.   "publisher" publisher field.or.null output.check
  555.   address field.or.null output
  556.   format.edition output
  557.   "year" format.date output.check
  558.   note field.or.null output
  559.   fin.entry
  560. }
  561.  
  562. FUNCTION {booklet}
  563. { output.bibitem
  564.   format.authors output
  565.   "title" format.btitle output.check
  566.   howpublished field.or.null output
  567.   address field.or.null output
  568.   format.date output
  569.   note field.or.null output
  570.   fin.entry
  571. }
  572.  
  573. FUNCTION {inbook}
  574. { output.bibitem
  575.   author missing$
  576.     { "author and editor" format.eds output.check }
  577.     { "author" format.authors output.check }
  578.   if$
  579.   "title" format.btitle output.check
  580.   "chapter and pages" format.chapter.pages output.check
  581.   format.bvolume output
  582.   "publisher" publisher field.or.null output.check
  583.   address field.or.null output
  584.   format.edition output
  585.   "year" format.date output.check
  586.   note field.or.null output
  587.   fin.entry
  588. }
  589.  
  590. FUNCTION {incollection}
  591. { output.bibitem
  592.   "authors" format.authors output.check
  593.   "title" format.title output.check
  594.   "booktitle" format.in.booktitle.ed output.check
  595.   format.chapter.pages output
  596.   "publisher" publisher field.or.null output.check
  597.   address field.or.null output
  598.   "year" format.date output.check
  599.   note field.or.null output
  600.   fin.entry
  601. }
  602.  
  603. FUNCTION {inproceedings}
  604. { output.bibitem
  605.   "author" format.authors output.check
  606.   "title" format.title output.check
  607.   "booktitle" format.in.booktitle.ed output.check
  608.   format.pages output
  609.   organization field.or.null output
  610.   publisher field.or.null output
  611.   address field.or.null output
  612.   "year" format.date output.check
  613.   note field.or.null output
  614.   fin.entry
  615. }
  616.  
  617. FUNCTION {conference} { inproceedings }
  618.  
  619. FUNCTION {manual}
  620. { output.bibitem
  621.   format.authors output
  622.   "title" format.btitle output.check
  623.   organization field.or.null output
  624.   address field.or.null output
  625.   format.edition output
  626.   format.date output
  627.   note field.or.null output
  628.   fin.entry
  629. }
  630.  
  631. FUNCTION {mastersthesis}
  632. { output.bibitem
  633.   "author" format.authors output.check
  634.   "title" format.btitle output.check
  635.   "Master's thesis" output
  636.   "school" school field.or.null output.check
  637.   address field.or.null output
  638.   "year" format.date output.check
  639.   note field.or.null output
  640.   fin.entry
  641. }
  642.  
  643. FUNCTION {misc}
  644. { output.bibitem
  645.   format.authors output
  646.   format.title output
  647.   howpublished field.or.null output
  648.   format.date output
  649.   note field.or.null output
  650.   fin.entry
  651. }
  652.  
  653. FUNCTION {phdthesis}
  654. { output.bibitem
  655.   "author" format.authors output.check
  656.   "title" format.btitle output.check
  657.   "PhD thesis" output
  658.   "school" school field.or.null output.check
  659.   address field.or.null output
  660.   "year" format.date output.check
  661.   note field.or.null output
  662.   fin.entry
  663. }
  664.  
  665. FUNCTION {proceedings}
  666. { output.bibitem
  667.   editor missing$
  668.     { organization missing$
  669.     'skip$
  670.     { organization field.or.null output }
  671.       if$
  672.     }
  673.     { format.editors output }
  674.   if$
  675.   "title" format.btitle output.check
  676.   editor missing$
  677.     'skip$
  678.     { organization field.or.null output }
  679.   if$
  680.   publisher field.or.null output
  681.   address field.or.null output
  682.   "year" format.date output.check
  683.   note field.or.null output
  684.   fin.entry
  685. }
  686.  
  687. FUNCTION {techreport}
  688. { output.bibitem
  689.   "author" format.authors output.check
  690.   "title" format.btitle output.check
  691.   format.tr.number output
  692.   "institution" institution field.or.null output.check
  693.   address field.or.null output
  694.   "year" format.date output.check
  695.   note field.or.null output
  696.   fin.entry
  697. }
  698.  
  699. FUNCTION {unpublished}
  700. { output.bibitem
  701.   "author" format.authors output.check
  702.   "title" format.title output.check
  703.   format.date output
  704.   "note" note field.or.null output.check
  705.   fin.entry
  706. }
  707.  
  708. FUNCTION {default.type} { book }
  709.  
  710. MACRO {jan} {"January"}
  711.  
  712. MACRO {feb} {"February"}
  713.  
  714. MACRO {mar} {"March"}
  715.  
  716. MACRO {apr} {"April"}
  717.  
  718. MACRO {may} {"May"}
  719.  
  720. MACRO {jun} {"June"}
  721.  
  722. MACRO {jul} {"July"}
  723.  
  724. MACRO {aug} {"August"}
  725.  
  726. MACRO {sep} {"September"}
  727.  
  728. MACRO {oct} {"October"}
  729.  
  730. MACRO {nov} {"November"}
  731.  
  732. MACRO {dec} {"December"}
  733.  
  734. MACRO {bssa} {"Bull. Seis. Soc. Am."}
  735.  
  736. MACRO {grl} {"Geophys. Res. Lett."}
  737.  
  738. MACRO {jgr} {"J. Geophys. Res."}
  739.  
  740. MACRO {jgsa} {"J. Geol. Soc. Am."}
  741.  
  742. MACRO {mit} {"Mass. Inst. of Tech."}
  743.  
  744. MACRO {usgs} {"U.S. Geol. Surv."}
  745.  
  746. READ
  747.  
  748. FUNCTION {sortify}
  749. { purify$
  750.   "ll" change.case$
  751. }
  752.  
  753. FUNCTION {format.label.names}
  754. { 's swap$ :=
  755.   'numnames s num.names$ :=
  756.   numnames #1 >
  757.     { numnames #2 >
  758.     { 'namesleft #1 := }
  759.     { 'namesleft numnames := }
  760.       if$
  761.       'nameptr #1 :=
  762.       'nameresult "" :=
  763.     { namesleft #0 > }
  764.     { nameptr numnames =
  765.         { s nameptr "{ff}{vv}{ll}{jj}" format.name$ "others" =
  766.         { 'nameresult nameresult " et al." * := }
  767.         { nameresult "" =
  768.             'skip$
  769.             { 'nameresult nameresult " and " * := }
  770.           if$
  771.           'nameresult nameresult s nameptr "{vv}{ll}" format.name$
  772.           * :=
  773.         }
  774.           if$
  775.         }
  776.         { 'nameresult nameresult s nameptr "{vv}{ll}" format.name$
  777.           * :=
  778.         }
  779.       if$
  780.       'nameptr nameptr #1 + :=
  781.       'namesleft namesleft #1 - :=
  782.     }
  783.       while$
  784.       numnames #2 >
  785.     { 'nameresult nameresult " et al." * := }
  786.     'skip$
  787.       if$
  788.     }
  789.     { 'nameresult s #1 "{vv}{ll}" format.name$ :=
  790.     }
  791.   if$
  792.   nameresult
  793. }
  794.  
  795. FUNCTION {calc.label}
  796. { 'label
  797.   author missing$
  798.     { editor missing$
  799.     { key missing$
  800.         { "Warning: need a key to make a label in " cite$ * top$
  801.           title field.or.null purify$ #1 #3 substring$
  802.         }
  803.         { key purify$ #1 #3 substring$ }
  804.       if$
  805.     }
  806.     { editor format.label.names }
  807.       if$
  808.     }
  809.     { author format.label.names }
  810.   if$
  811.   add.comma
  812.   year field.or.null purify$
  813.   *
  814.   :=
  815.   'sort.label label sortify :=
  816. }
  817.  
  818. FUNCTION {sort.format.names}
  819. { 's swap$ :=
  820.   'nameptr #1 :=
  821.   'nameresult "" :=
  822.   'numnames s num.names$ :=
  823.   'namesleft numnames :=
  824.     { namesleft #0 > }
  825.     { nameptr #1 >
  826.     { 'nameresult nameresult "   " * := }
  827.     'skip$
  828.       if$
  829.  
  830.       't s nameptr "{vv{ } }{ll{ }}{  f{ }}{  jj{ }}" format.name$ :=
  831.  
  832.       nameptr numnames = t "others" = and
  833.     { 'nameresult nameresult "et al" * := }
  834.     { 'nameresult nameresult t sortify * := }
  835.       if$
  836.       'nameptr nameptr #1 + :=
  837.       'namesleft namesleft #1 - :=
  838.     }
  839.   while$
  840.   nameresult
  841. }
  842.  
  843. INTEGERS {len}
  844.  
  845. FUNCTION {chop.word}
  846. { 's swap$ :=
  847.   'len swap$ :=
  848.   s #1 len substring$ =
  849.     { s len #1 + global.string.max substring$ }
  850.     { s }
  851.   if$
  852. }
  853.  
  854. FUNCTION {sort.format.title}
  855. { 't swap$ :=
  856.   "A " #2
  857.     "An " #3
  858.       "The " #4 t chop.word
  859.     chop.word
  860.   chop.word
  861.   #1 global.string.max substring$
  862.   sortify
  863. }
  864.  
  865. FUNCTION {presort}
  866. {
  867.  
  868.   calc.label
  869.   sort.label
  870.   "    "
  871.   *
  872.  
  873.   author missing$
  874.     { editor missing$
  875.     { key field.or.null sortify }
  876.     { editor sort.format.names }
  877.       if$
  878.     }
  879.     { author sort.format.names }
  880.   if$
  881.  
  882.   *
  883.  
  884.   "    "
  885.   *
  886.   title field.or.null
  887.   sort.format.title
  888.   *
  889.   #1 entry.string.max substring$
  890.   'sort.key$ swap$ :=
  891. }
  892.  
  893. ITERATE {presort}
  894.  
  895. SORT
  896.  
  897. STRINGS { longest.label last.sort.label next.extra }
  898.  
  899. INTEGERS { longest.label.width last.extra.num }
  900.  
  901. FUNCTION {initialize.longest.label}
  902. { 'longest.label "" :=
  903.   'last.sort.label "" :=
  904.   'next.extra "" :=
  905.   'longest.label.width #0 :=
  906.   'last.extra.num #0 :=
  907. }
  908.  
  909. FUNCTION {forward.pass}
  910. { last.sort.label sort.label =
  911.     { 'last.extra.num last.extra.num #1 + :=
  912.       'extra.label last.extra.num int.to.chr$ :=
  913.     }
  914.     { 'last.extra.num "a" chr.to.int$ :=
  915.       'extra.label "" :=
  916.       'last.sort.label sort.label :=
  917.     }
  918.   if$
  919. }
  920.  
  921. FUNCTION {reverse.pass}
  922. { next.extra "b" =
  923.     { 'extra.label "a" := }
  924.     'skip$
  925.   if$
  926.   'label label extra.label * :=
  927.   label width$ longest.label.width >
  928.     { 'longest.label label :=
  929.       'longest.label.width label width$ :=
  930.     }
  931.     'skip$
  932.   if$
  933.   'next.extra extra.label :=
  934. }
  935.  
  936. EXECUTE {initialize.longest.label}
  937.  
  938. ITERATE {forward.pass}
  939.  
  940. REVERSE {reverse.pass}
  941.  
  942. FUNCTION {preamble}
  943. { "\begin{thebibliography}{X}" write$
  944.   newline$
  945. }
  946.  
  947. EXECUTE {preamble}
  948.  
  949. EXECUTE {init.state.consts}
  950.  
  951. ITERATE {call.type$}
  952.  
  953. FUNCTION {finish.up} { newline$ "\end{thebibliography}" write$ newline$ }
  954.  
  955. EXECUTE {finish.up}
  956.